---
layout: "default"
title: "CVarArgType"
description: "Swift documentation for 'CVarArgType': Instances of conforming types can be encoded, and appropriately
passed, as elements of a C va_list."
keywords: "CVarArgType,protocol,swift,documentation"
root: "/v2.1"
---

<div class="intro-declaration"><code class="language-swift">protocol CVarArgType</code></div>

<div class="discussion comment">
    <p>Instances of conforming types can be encoded, and appropriately
passed, as elements of a C <code>va_list</code>.</p>

<p>This protocol is useful in presenting C &quot;varargs&quot; APIs natively in
Swift.  It only works for APIs that have a <code>va_list</code> variant, so
for example, it isn&#39;t much use if all you have is:</p>

<pre><code class="language-swift">int f(int n, ...)</code></pre>

<p>Given a version like this, though,</p>

<pre><code class="language-swift">int f(int, va_list arguments)</code></pre>

<p>you can write:</p>

<pre><code class="language-swift">func swiftF(x: Int, arguments: CVarArgType...) -&gt; Int {
  return withVaList(arguments) { f(x, $0) }
}</code></pre>
</div>

<table class="standard">
<tr>
<th id="inheritance">Inheritance</th>
<td>
<span class="viz"><a href="hierarchy/">View Protocol Hierarchy &rarr;</a></span>
</td>
</tr>



<tr>
<th>Import</th>
<td><code class="language-swift">import Swift</code></td>
</tr>

</table>









